package _4策略模式.加密_解密文件;

import java.io.*;

public class Application {

	public static void main(String[] args) {
		File fileOne = new File("./src/_4策略模式/加密_解密文件/A.txt");
		String s = "";
		EncodeContext context = new EncodeContext();
		context.setStrategy(new StrategyOne("hello,world!"));       // 使用策略 1
		context.encryptFile(fileOne);
		System.out.println(fileOne.getName() + "加密后的内容");
		try {
			FileReader inOne = new FileReader(fileOne);
			BufferedReader inTwo = new BufferedReader(inOne);
			while ((s = inTwo.readLine()) != null) {
				System.out.println(s);
			}
			inTwo.close();
			inOne.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String str = context.decryptFile(fileOne);
		System.out.println(fileOne.getName() + "解密后的内容");
		System.out.println(str);
	}
}
